package com.hrt.datasender.datadao.service;

import java.util.List;

import com.hrt.datasender.datadao.model.BcAccessTableModel;
import com.hrt.datasender.datadao.model.BcSendPlatformModel;
import com.hrt.db.DBManager;

/**
 * 
 * <pre>
 * 注释
 * </pre>
 * 
 * @author FAN
 * @date 2018年9月12日下午5:22:41
 */
public final class BcAccessTableService {

    private static volatile BcAccessTableService instance;

    private BcAccessTableService() {

    }

    public static BcAccessTableService getInstance() {
        if (instance == null) {
            synchronized (BcAccessTableService.class) {
                if (instance == null) {
                    instance = new BcAccessTableService();
                }
            }
        }
        return instance;
    }

    public BcAccessTableModel getModel(BcSendPlatformModel sendPlatForm) {

        BcAccessTableModel model = new BcAccessTableModel();

        model.setId(sendPlatForm.getPlatformId());

        model = DBManager.getORMExecuter().getModel(model);

        return model;
    }

    public List<BcAccessTableModel> getModels() {

        return DBManager.getORMExecuter().getModelList(BcAccessTableModel.class, null,null).getData();
    }

    public BcAccessTableModel create(BcAccessTableModel bcAccess) {

        DBManager.getORMExecuter().create(bcAccess);

        return bcAccess;
    }

    public BcAccessTableModel update(BcAccessTableModel model) {
        DBManager.getORMExecuter().update(model);
        return model;
    }

    public void delete(String id) {
        BcAccessTableModel model = new BcAccessTableModel();
        model.setId(id);
        DBManager.getORMExecuter().delete(model);
    }

}
